﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Nivdal.AuxCode
{
    public class OnlineUser
    {
        public string UserId { get; set; }
        public string TeamId { get; set; }
        public string Language { get; set; }
        public string UserAccessLevel { get; set; }
        public string UserName { get; set; }
        public bool IsPremium { get; set; }
        public string ApprovalStatus { get; set; }
        public string UICulture { get; set; }
        public string Culture { get; set; }
        public string TextDir { get; set; }
        public string Country { get; set; }
        public string CountryName { get; set; }
        public string Newspaper { get; set; }
        public string NewsPaperPrivsLevel { get; set; }
        public bool CanPlayFriendlies { get; set; }
        public bool IsQnAEditor { get; set; }
        public string NationalTeamCoach { get; set; }
        public bool PremiumEnabled { get; set; }
        public string NationalTeamId { get; set; }
        public string U19TeamId { get; set; }
        public string NationalTeamName { get; set; }
        public string U19TeamName { get; set; }
        public string TranslatesTo { get; set; }
        public string TopAreaImage { get; set; }


        public bool IsRTL()
        {
            if (Language == "3")
                return true;
            return false;
        }

        public void RefreshOU()
        {
            GetNivdalData.GetNivdalData GND = new GetNivdalData.GetNivdalData();
            UserId = GND.ReturnUserId();
            UserName = GND.ReadNivdalStringData("UserId", "Nivdal_GetUserNameById", UserId);
            TeamId = GND.ReadNivdalIntData("@UserId", "Nivdal_GetTeamIdByUserId", UserId);
            UserAccessLevel = GND.ReadNivdalIntData("@UserId", "Nivdal_GetUserLevel", UserId);
            Language = GND.GetUserLanguage();
            IsPremium = GND.IsUserPremium();
            ApprovalStatus = (GND.ReadNivdalIntData("@UserId", "Nivdal_GetUserApprovalStatus", UserId));
            Culture = GND.ReadNivdalStringData("Language_Code", "Nivdal_GetLanguageCulture", Language);
            UICulture = GND.ReadNivdalStringData("Language_Code", "Nivdal_GetLanguageUICulture", Language);
            TextDir = GND.ReadNivdalStringData("Language_Code", "Nivdal_GetLanguageTextDirection", Language);
            Country = GND.ReadNivdalIntData("UserId", "Nivdal_GetCountryByUser", UserId);
            CountryName = GND.ReadNivdalStringData("UserId", "Nivdal_GetCountryNameForUser", UserId);
            Newspaper = GND.ReadNivdalIntData("Country", "Nivdal_GetNewspaperByUser", Country);
            NewsPaperPrivsLevel = GND.ReadNivdalIntData("UserId", "NewsPapaerId", "Nivdal_GetNewsPaperPrivsLevel", UserId, Newspaper);
            CanPlayFriendlies = GND.ReadNivdalBoolData("TeamId", "Nivdal_FriendlyCanTeamPlayFriendlies", TeamId);
            IsQnAEditor = GND.ReadNivdalBoolData("UserId", "Nivdal_IsUserQnATipEditor", UserId);
            NationalTeamCoach = GND.ReadNivdalIntData("UserId", "Nivdal_NTIsUserNationalTeamCoachProc", UserId);
            PremiumEnabled = GND.ReadNivdalBoolData("UserId", "Nivdal_IsPremiumEnabled", UserId);
            NationalTeamId = GND.ReadNivdalIntData("CountryId", "Nivdal_GetNationalTeamByCountry", Country);
            U19TeamId = GND.ReadNivdalIntData("CountryId", "Nivdal_GetU19TeamByCountry", Country);
            TopAreaImage = GND.ReadNivdalStringData("UserId", "Nivdal_GetTopAreaImage", UserId);
            if (NationalTeamId != "0")
                NationalTeamName = GND.ReadNivdalStringData("TeamId", "Nivdal_GetNationalTeamNameById", NationalTeamId);
            else
                NationalTeamName = "";
            
            if (U19TeamId != "0")
                U19TeamName = GND.ReadNivdalStringData("TeamId", "Nivdal_GetNationalTeamNameById", U19TeamId);
            else
                U19TeamName = "";

            TranslatesTo = GND.ReadNivdalIntData("UserId", "Nivdal_GetUserTranslateLanguage", UserId);
        }
    }
}